<%@ page import="entity.User" %><%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2023/10/24
  Time: 15:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页</title>
</head>
<body>
<!--
    访问当前页面时判断用户是否已经登录
    如果用户未登录,则显示下方的注册与登录的链接
-->
<%
    User user = (User) session.getAttribute("user");
    if(null == user){
%>
<a href="">注册</a>
<a href="<%=request.getContextPath()%>/session/login.jsp">登录</a>
<%
    } else{
%>
<!--
    如果用户已经登录了,则显示下方的欢迎与注销功能
-->
欢迎您:<%=user.getUsername()%>
<a href="<%=request.getContextPath()%>/logout">注销</a>
<%
    }
%>
</body>
</html>
